package com.gasolinator.a;

import com.gasolinator.a.app.helper.DistanceHelper;
import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

/**
 * Created by IntelliJ IDEA.
 * User: fjhidalgo
 * Date: 16/12/11
 * Time: 11:06
 * To change this template use File | Settings | File Templates.
 */
public class DistanceHelperTest {

    @DataProvider(name = "distances")
    Object[][] getLocationData(){
        return new Object[][]{
                {41.3319,2.1111,40.27,3.24,151561.23452345234},
                {41.3319,2.1111,40.24,-3.40,479516.786567}, // bcn to mad
                {41.34227804675232,1.690521240234375,42.34227804675232,1.690521240234375,111194.151254234523},
                {51.342299,4.371359, 51.342490,4.371997,49.1} //google earth says ~136m
        };
    }
    @Test(dataProvider = "distances")
    public void testHaversineFormula_returnsMeters(double a,double b,double c,double d,double expected) throws Exception {
        double actual = DistanceHelper.haversineFormula(a,b,c,d);
        Assert.assertEquals((int)actual,(int)expected);

    }
    @Test(dataProvider = "distances")
    public void testCosineFormula_returnsMeters(double a,double b,double c,double d,double expected) throws Exception {
        double actual = DistanceHelper.cosineFormula(a,b,c,d);
        Assert.assertEquals((int)actual,(int)expected);

    }

}
